import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Panel;

public class JAPI_Panel extends Panel
{
	private static final long serialVersionUID = 5629438119334512097L;
	
	Insets inset;
	int type=1;

	public JAPI_Panel(int t)
	{
		super(); 
	     	type = t;
		this.setLayout(new JAPI_Fixlayout());
		if(t!=JAPI_Const.J_NONE)
			inset = new Insets(4,4,4,4);
	}

	public void setEnabled(boolean b) {
		for(int i=0;i<getComponentCount();i++)
			getComponent(i).setEnabled(b);
	}
	
	public void setInsets(int t, int b, int l, int r)
	{
		inset = new Insets(t,l,b,r);
	}

	public Insets getInsets()
	{
		if(inset != null)
			return(inset);
		else
			return(super.getInsets());
	}
	
	public void setFont(Font f)
    {
		int i;
   		super.setFont(f);
		for(i=0;i<getComponentCount();i++)
			if(getComponent(i).isDisplayable())
				getComponent(i).setFont(f);
   	}
	
	public void paint(Graphics g) 
 	{
        Dimension d = getSize();
        Color bg = getBackground();
 
        g.setColor(bg);
        
        switch(type)
        {
        	case(JAPI_Const.J_LINEDOWN):	/* Linie down */
        				g.draw3DRect(1, 1, d.width-2, d.height-2, false);
        				g.draw3DRect(2, 2, d.width-4, d.height-4, true);
						break;
			case(JAPI_Const.J_LINEUP):	/* Linie up */
				        g.draw3DRect(1, 1, d.width-2, d.height-2, true);
				        g.draw3DRect(2, 2, d.width-4, d.height-4, false);
						break;
			case(JAPI_Const.J_AREADOWN):	/* Flaeche down */
				        g.draw3DRect(1, 1, d.width-2, d.height-2, false);
//				        g.draw3DRect(2, 2, d.width-4, d.height-4, false);
						break;
        	case(JAPI_Const.J_AREAUP):	/* Flaeche up */
				        g.draw3DRect(1, 1, d.width-2, d.height-2, true);
//				        g.draw3DRect(2, 2, d.width-4, d.height-4, true);
    	}
    }
}
